<template>
    <div class="box">
        <div class="null-page" v-show="yes"></div>
        <el-card class="box-card member-coupon">
            <div slot="header" class="clearfix"><el-button type="primary" @click="addAddress">增加</el-button></div>
            <div class="my-account">
                <div class="detail">
                    <el-table :data="accountList" border>
                        <el-table-column label="头像" width="80"  >
                            <template slot-scope="scope" style="height: 30px">
                                <img v-if="!scope.row.headimg" :src="circleUrl" alt="" style="width: 30px; height: 30px; " />
                                <img v-else :src="scope.row.headimg" alt="" style="width: 30px; height: 30px;" />
                            </template>
                        </el-table-column>
                        <el-table-column prop="username" label="账号" ></el-table-column>
                        <el-table-column prop="nickname" label="姓名" width="100" ></el-table-column>
                        <el-table-column prop="member_level_name" class="detail-name" label="用户等级" ></el-table-column>
                        <el-table-column :formatter="dateFormat" label="注册时间" >
                            <template slot-scope="scope">
                                  <span> {{ $util.timeStampTurnTime(scope.row.reg_time)}} </span>   
                            </template>
                        </el-table-column>
                        <el-table-column label="修改" >
                            <template slot-scope="scope">
                                <el-button size="mini" type="danger" @click="hansda(scope.row.member_id)"> 修改 </el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
                <div class="pager">
                    <el-pagination background :pager-count="5" :total="total" prev-text="上一页" next-text="下一页" :current-page.sync="account.page" :page-size.sync="account.page_size" @size-change="handlePageSizeChange" @current-change="handleCurrentPageChange" hide-on-single-page></el-pagination>
                </div>
            </div>
        </el-card>
    </div>
</template>

<script>
import moment from "moment"
import { getChildAccount } from "@/api/member/zijiguanli"

export default {
    name: "zijiguanli",

    data: () => {
        return {
            account: {
                page: 1,
                page_size: 10
            },
            circleUrl: "http://localhost/subject_baishangwanqihui/app/admin/view/public/img/default_headimg.png",
            accountList: [],
            total: 0,
            integer: 0,
            decimal: 0,
            yes: true
        }
    },
    created() {
        this.getcompany()
    },
    mounted() {
        let self = this
        setTimeout(function () {
            self.yes = false
        }, 300)
    },
    methods: {
        getcompany() {
            getChildAccount({
                page_size: this.account.page_size,
                page: this.account.page,
                account_type: "balance"
            })
                .then((res) => {
                    if (res.code == 0 && res.data) {
                        this.accountList = res.data.list
                        this.total = res.data.count
                       
                    }
                })
                .catch((err) => {
                    this.$message.error(err.message)
                })
        },

        handlePageSizeChange(num) {
            this.account.page_size = num
            this.getcompany()
        },
        handleCurrentPageChange(page) {
            this.account.page = page
            this.getcompany()
        },
        dateFormat(row, column) {
            var date = row[column.property]
            if (date == undefined) {
                return ""
            }
            var moment = require("moment")
            return moment(date).format("YYYY-MM-DD HH:mm:ss")
        },

        addAddress() {
            this.$router.push({ path: "/member/construction" })
        },

        hansda(item) {
            this.$router.push({ path: "/member/modification", query: { member_id: item } })
        }
    }
}
</script>
<style lang="scss" scoped>
.box {
    width: 100%;
    position: relative;
}

.null-page {
    width: 100%;
    height: 730px;
    background-color: #ffffff;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 9;
}
.el-table .cell {
    height: 30px !important;
}
</style>
